import request from "@/axios"

//获取地址列表
export function listAddress() {
    let url = '/api/order/address'
    return request.get(url)
}

//更新地址
export function mergeAddress(address) {
    let url = '/api/order/address'
    let data = address
    data.Loading = true
    return request.post(url, data)
}

//获取地址
export function getAddress(id) {
    let url = '/api/order/address/info'
    let params = {id}
    return request.get(url, {params})
}

//移除地址
export function removeAddress(id) {
    let url = '/api/order/address/remove'
    let params = {id}
    return request.get(url, {params})
}



//提交订单
export function commitOrder(address) {
    let url = '/api/order/cart/commit'
    let data = address
    data.Loading = true
    return request.post(url, data)

}

//查询订单
export function listOrder(page,orderType,busType) {
    let url = '/api/order/list'
    let limit = 5
    let params = {page, limit,orderType,busType}
    return request.get(url, {params})
}

//查询订单
export function listShareOrder(page,type) {
    let url = '/api/order/share/list'
    let limit = 5
    let params = {page, limit,type}
    return request.get(url, {params})
}

//获取订单
export function getOrder(id, orderNo,type) {
    let url = '/api/order/info'
    let params = {id, orderNo,type}
    return request.get(url, {params})
}

//移除订单
export function removeOrder(orderId) {
    let url = '/api/order/remove'
    let data = {
        orderId,
        Loading: true
    }
    return request.post(url, data)
}
export function removeShopOrder(orderId) {
    let url = '/api/shop/cancel'
    let data = {
        orderId,
        Loading: true
    }
    return request.post(url, data)
}

//统一下单
export function unionPay(orderNo) {
    let url = '/api/order/wx/union'
    let data = {orderNo}
    data.Loading = true
    return request.post(url, data)
}

//查询货物状态
export function searchReceived() {
    let url = '/api/order/findOrdersByStatus?status=2'

    return request.get(url)
}

//确认收货
export function sureReceipt(orderNo) {
    let url = '/api/order/sureReceipt'
    let params = {
        orderNo,
        Loading: true
    }
    return request.post(url, params)
}

export function recursionOrder(info){
    let url =`/api/my/recursionOrderNo?info=${info}`
    return request.get(url)
}

export function getMyOrderList(orderStatus,payStatus,page,limit){

    let url ='/api/my/myOrderList'
    let params = {
        orderStatus,payStatus,page,limit
    }
    return request.get(url, {params})
}

export function getGoodsOrder(orderStatus,payStatus,page,limit) {
    let url=`api/shop/shopOrderList`
    let params = {
        orderStatus,payStatus,page,limit
    }

    return request.get(url,{params})
}

//上传物流单号

export function uploadLogNo(orderId,logNo,logCompany,logFee) {
    let url = `api/shop/apiUpload`
    let params = {orderId,logNo,logCompany,logFee}
    // let query = upload
    // console.log(query)
    return request.get(url,{params})
}
//查询物流信息
export function logistics(no){
    let url =`/api/logistics/find?no=${no}`
    return request.get(url)
}
export function isGet(orderId) {
    let url = '/api/shop/mention'
    let params = {
        orderId,
        Loading: true
    }
    return request.post(url, params)
}

export function upLoadAppraise(goodsId,itemId,content) {
    let url = '/api/comment/comment'
    let params = {
        goodsId,
        itemId,
        content
    }
    console.log(params);
    return request.post(url,params)
}

export function getAppraise(goodsId,page) {
    let url = '/api/comment/getComments'
    let params = {goodsId,page,limit:10}
    return request.get(url,{params})
}

export function getWithdrawList(page,identify) {
    let url = `/api/cashApply/list?page=${page}&limit=15&identify=${identify}`
    return request.get(url)
}

export function getBankList() {
    let url = '/api/accCard/accList'
    return request.get(url)
}

export function saveBankCard(accName,bank,accBranch,number) {
    let url = '/api/accCard/save'
    let params ={
        accName,
        bank,
        accBranch,
        number
    }
    return request.get(url, {params})
}

export function deleteBankCard(id) {
    let url=`/api/accCard/delete?id=${id}`
    return request.get(url)
}

export function editBankCard(id,accName,bank,accBranch,number) {
    let url = '/api/accCard/update'
    let params ={
        id,
        accName,
        bank,
        accBranch,
        number
    }
    return request.get(url, {params})
}

export function getCanWithdraw(page) {
    let url = '/api/cashApply/getApplyMoney?limit=8&flag=true&page='+page
    return request.get(url)
}

export function getShopWithdraw() {
    let url = '/api/cashApply/getApplyMoney?limit=8&page=1&flag=false'
    return request.get(url)
}

